<head>
   <meta http-equiv="Content-Type" content="text/html" charset="utf-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <meta name="description" content="">
   <meta name="keywords" content="">
   <meta name="author" content="">

   <title>Kuesioner Online</title>

   <link href="<?php echo base_url('assets/css/bootstrap.min.css') ?>" rel="stylesheet">
   <link href="<?php echo base_url('assets/css/font-awesome.css') ?>" rel="stylesheet">
   <link href="<?php echo base_url('assets/css/custom.css') ?>" rel="stylesheet">

   <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
   <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
   <script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/1.3.1/lodash.min.js"></script>
   <script src="<?php echo base_url('assets/js/jquery.min.js') ?>"></script>
   <script src="<?php echo base_url('assets/js/bootstrap.min.js') ?>"></script>
   <script src="<?php echo base_url('assets/js/custom.js') ?>"></script>
</head>

<body class=" safesearch-installed" style="background-color:#fff">
<div style="background-color:#fff; margin-top:-15px; margin-left: 150px; margin-right: 150px; box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.1)">
	<div style="margin-left: 25px; margin-right: 25px; padding-top:15px; padding-bottom:15px">
		<div class="container-fluid">
			<div>
			<h3 align="center"><?php echo $kuesioner[0]['nama_kuesioner'];?></h3>
			<h4 align="center"><?php echo $kuesioner[0]['deskripsi'];?></h4>
			</div>
			<form action="<?php echo base_url().'index.php/kuesioner/isi_kuesioner'?>" method="post" >
			<div class="form-group" style="margin-left:110px">
			<table class="table">
				<?php
				$nomor = 1;
				$skala = array();
				$pg = array();
				foreach($konten_teks as $konten_teks)
				{
						echo '<tr>';
						echo '<td>'.$nomor++.'</td>';
						echo '<td>'.$konten_teks['pertanyaan'].'</td>';
						echo '<td>:</td>';
						echo '<td style="word-wrap: break-word;max-width: 30px;"><input name="id_pertanyaan[]" value="'.$konten_teks['id_pertanyaan'].'" hidden></td>';
						if($konten_teks['fk_id_jenis_teks'] == 1){
						echo '<td colspan="7"><input type="date" class="form-control" name="jawab[]"></td>';
						} else{
								if($konten_teks['fk_id_jenis_teks'] == 2){
								echo '<td colspan="7"><input type="email" class="form-control" name="jawab[]" placeholder="asdasd@gmail.com"></td>';
								} else{
									echo '<td colspan="7"><input class="form-control" name="jawab[]"></td>';
									}
							}
						echo '</tr>';
				}
				
				foreach($konten_pg as $konten_pg)
						{
							$pg = explode(',', $konten_pg['pilihan']);
									echo '<tr>';
										echo '<td>'.$nomor++.'</td>';
										echo '<td  colspan="2" style="word-wrap: break-word;max-width: 30px;">'.$konten_pg['pertanyaan'].'</td>';
										echo '<td ><input name="id_pertanyaan[]" value="'.$konten_pg['id_pertanyaan'].'" hidden></td>';
										for($i = 0; $i < count($pg)-1; $i++)
										{
											echo '<td ><input type="checkbox" name="jawab[]" id="checkbox'.$nomor.'" value="'.$pg[$i].'">'.$pg[$i].'</td>';
										}
										echo '</tr>';
							
						}
				
				foreach($konten_skala as $konten_skala)
						{
								if(empty($skala)){
									echo '<tr>';
									echo '<td></td>';
									echo '<td></td>';
									echo '<td></td>';
									echo '<td></td>';
									$skala = explode(',', $konten_skala['skala']);
									//var_dump($skala);
									for($i = 0; $i < count($skala)-1; $i++)
									{
										echo '<td >'.$skala[$i].'</td>';
									}
									echo '</tr>';
									echo '<tr>';
										echo '<td>'.$nomor++.'</td>';
										echo '<td  colspan="2" style="word-wrap: break-word;max-width: 30px;">'.$konten_skala['pertanyaan'].'</td>';
										echo '<td ><input name="id_pertanyaan[]" value="'.$konten_skala['id_pertanyaan'].'" hidden></td>';
										for($i = 0; $i < count($skala)-1; $i++)
										{
											$cekbox = $i+1;
											echo '<td ><input type="checkbox" name="jawab[]" id="checkbox'.$nomor.'" value="'.$cekbox.'"></td>';
										}
										echo '</tr>';
								} else
									{
										echo '<tr>';
										echo '<td>'.$nomor++.'</td>';
										echo '<td colspan="2" style="word-wrap: break-word;max-width: 30px;">'.$konten_skala['pertanyaan'].'</td>';
										echo '<td ><input name="id_pertanyaan[]" value="'.$konten_skala['id_pertanyaan'].'" hidden></td>';
										for($i = 0; $i < count($skala)-1; $i++)
										{
											$cekbox = $i+1;
											echo '<td ><input type="checkbox" name="jawab[]" id="checkbox'.$nomor.'" value="'.$cekbox.'"></td>';
										}
										echo '</tr>';
									}
							
						}
					
					
				
				?>
			</table>
			</div>
			<div class="form-group" style="margin-left:110px">
			<button type="submit" class="btn btn-primary">Simpan</button>
			</div>
			
			</form>
		</div>
	</div>
</div>
</body>
<script>
		$("input:checkbox").change(function(){
		 var groupcekbox = ":checkbox[id='"+ $(this).attr("id") + "']";
		   if($(this).is(':checked')){
			 $(groupcekbox).not($(this)).attr("checked",false);
		   }
		 });
</script>